<?php
/* explain:		Popedom system
 * Project:     marsems
 * File:        Popedom.php
 *
 * @ link 		http://www.marems.com/lib/
 * @ Email		ldmmyx@hotmail.com
 * @ copyright 	2007  ivan.ling
 * @ author 	ivan.ling
 * @ version 	1.0
 *
 * @ --- function list ---
 * @ getNotPopedomInfo()	--> tip 
 */
include_once("DB.php");	
class Popedom extends DB 
{
	const STRING_WEB_VIEW	= 'web_view';
	const STRING_WEB_EDIT 	= 'web_edit';
	const STRING_WEB_ADD 	= 'web_add';
	const STRING_WEB_DELETE	= 'web_delete';
	
	const STRING_VIEW 		= '1';
	const STRING_ADD 		= '2';
	const STRING_LIVE 		= '3';
	const STRING_DELETE 	= '4';
	const STRING_EDIT 		= '5';
	const STRING_STOP 		= '6';
	
	const SYSTEM_SAFE_KEY 	= 'V!N@MY([RGF1*43$~';
	
	private $INT_ADMINISTRATOR_GROUP	= 1;
	private $INT_SYSTEM_ADMIN_GROUP		= 2;
	private $INT_COMMON_ADMIN_GROUP		= 4;
	private $INT_MEMBER_GROUP			= 6;
	
	private $STRING_NOT_POPEDOM_INFO = 'There has not operate popedom.';
	
	function Popedom()
	{
		parent::DB();
	}
	
	public function getNotPopedomInfo()
	{
		return $this->STRING_NOT_POPEDOM_INFO;
	}
	
	public function isUnallowableView($arrPopedom)
	{
		return is_array($arrPopedom) && in_array(Popedom::STRING_VIEW, $arrPopedom) ? false : true;
	}
	
	public function isUnallowableAdd($arrPopedom)
	{
		return is_array($arrPopedom) && in_array(Popedom::STRING_ADD, $arrPopedom) ? false : true;
	}
	
	public function isUnallowableLive($arrPopedom)
	{
		return is_array($arrPopedom) && in_array(Popedom::STRING_LIVE, $arrPopedom) ? false : true;
	}
	
	public function isUnallowableDelete($arrPopedom)
	{
		return is_array($arrPopedom) && in_array(Popedom::STRING_DELETE, $arrPopedom) ? false : true;
	}
	
	public function isUnallowableEdit($arrPopedom)
	{
		return is_array($arrPopedom) && in_array(Popedom::STRING_EDIT, $arrPopedom) ? false : true;
	}

	public function isUnallowableWait($arrPopedom)
	{
		return is_array($arrPopedom) && in_array(Popedom::STRING_WAIT, $arrPopedom) ? false : true;
	}
	
	public function isUnallowable($arrPopedom, $popedom)
	{
		return is_array($arrPopedom) && in_array($popedom, $arrPopedom) ? false : true;
	}
	
	
	public function getWebViewPopedom()
	{
		return Popedom::STRING_WEB_VIEW.__METHOD__.__LINE__;
	}
	
	
	public function getEditPopedom()
	{
		return Popedom::STRING_WEB_EDIT.__METHOD__.__LINE__;
	}
	
	public function getAddPopedom()
	{
		return Popedom::STRING_ADD_EDIT.__METHOD__.__LINE__;
	}
	
	public function getDeletePopedom()
	{
		return Popedom::STRING_EDIT_EDIT.__METHOD__.__LINE__;
	}
	
	public function isAdmin($groupid)
	{
		if($this->INT_COMMON_ADMIN_GROUP == $groupid || $this->INT_SYSTEM_ADMIN_GROUP == $groupid || $this->INT_ADMINISTRATOR_GROUP == $groupid)
			return true;
		else
			return false;
	}
	
	public function isMember($groupid)
	{
		if($this->INT_MEMBER_GROUP == $groupid)
			return true;
		else
			return false;
	}
}


?>
